/* 
 * File:   Field.cpp
 * Author: Lucky
 * 
 * Created on 5. říjen 2011, 10:57
 */

#include "Field.h"

Field::Field(int length) {
    m_length = length;
    m_end = -1;
    m_field = new bool[m_length];
    m_switchCount = 0;
    for (int i = 0; i < m_length; i++) {
        m_field[i] = false;
    }
}

Field::Field(const Field& orig) {
    throw "None copy constructor in field";
}

Field::~Field() {
    delete m_field;
}

int Field::getSwitchCount() const {
    return m_switchCount;
}

void Field::setState(int p, bool state) {
    if (m_field[p] != state) {
        if (state) {
            ++m_switchCount;
        } else {
            --m_switchCount;
        }
    }
    m_field[p] = state;
}

 

